package com.design.components;

import java.util.List;

import com.data.IdManager;

public abstract class DesignComponent {
	
	//**************************************************************************************************
	//	Constructor.
	//**************************************************************************************************
	
	public DesignComponent(byte prefix) {
		this.id = IdManager.getNewId(prefix);
		this.name = "";
	}
	
	public DesignComponent(byte prefix, String name) {
		this.id = IdManager.getNewId(prefix);
		this.name = name;
	}
	
	//**************************************************************************************************
	//	Attributes.
	//**************************************************************************************************
	
	protected int id;
	protected String name;
	
	//**************************************************************************************************
	//	Public Methods.
	//**************************************************************************************************
	
	/**
	 * This method is supposed to receive two lists. In the first one, the attributes names
	 * will be dump, and in the second one the attributes values. </br>
	 * Just the common attributes for all classes will be dump into the lists.
	 * @param names Where the names of the common attributes of the class are going to be put.
	 * @param values Where the values of the common attributes of the class are going to be put.
	 * */
	public void dumpCommonAttributes(List <String> names, List <String> values) {
		names.add("Id");
		names.add("Name");
		values.add(Integer.toString(id));
		values.add(name);
	}
	
	/**
	 * Abstract method. This method is supposed to receive two lists. In the first one, the attributes names
	 * will be dump, and in the second one the attributes values. </br>
	 * This is going to be implemented by each class, because just them know its structure. In this way
	 * we are abstracting from the attributes of each class.
	 * @param names Where the names of the attributes of the class are going to be put.
	 * @param values Where the values of the attributes of the class are going to be put.
	 * */
	public abstract void dumpAttributes(List <String> names, List <String> values);

	/**
	 * Receive the only editable component attrbute (the name).
	 * @param name The new name of the component.
	 * */
	public void keepCommonAttributes(String name) {
		this.name = name;
	}
	
	/**
	 * Abstract method. Receives a list with the attributes values. </br>
	 * This is going to be implemented by each class, because just them know its structure. In this way
	 * we are abstracting from the attributes of each class.</br>
	 * The aim of this method is that the componets keeps the values contained in the list.
	 * @param values The values to be kept by the component.
	 * */
	public abstract void keepAttributes(List <String> values);
	
	//**************************************************************************************************
	//	Getters & Setters.
	//**************************************************************************************************
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	//**************************************************************************************************
	//	Inner Classes.
	//**************************************************************************************************
}
